package com.nova.android.tvlauncher.ui.activity.atv

import com.nova.android.tvlauncher.R
import com.nova.android.tvlauncher.databinding.ActivityCommonRightPanelAtvBinding
import com.nova.android.tvlauncher.ext.navigateBack
import com.nova.android.tvlauncher.ui.fragment.atv.CustomChannelATVFragment
import com.nova.android.tvlauncher.ui.fragment.atv.NotificationATVFragment
import com.nova.android.tvlauncher.ui.fragment.atv.SelectAppATVFragment
import com_github_lib_base.base.BaseVMActivity
import com_github_lib_base.base.BaseViewModel
import com_github_lib_base.ext.replaceFragment

class CommonRightPanelAtvActivity: BaseVMActivity<ActivityCommonRightPanelAtvBinding, BaseViewModel>() {
    override fun initView() {
        val type = intent.getStringExtra(TYPE)
        when (type) {
            SELECT_APP_FRAGMENT -> {
                replaceFragment(SelectAppATVFragment.Companion.newInstance(), R.id.fl_container)
            }

            SYS_NOTIFICATION_FRAGMENT -> {
                replaceFragment(NotificationATVFragment.Companion.newInstance(), R.id.fl_container)
            }

            CUSTOME_CHANNEL_FRAGMENT -> {
                replaceFragment(CustomChannelATVFragment.Companion.newInstance(), R.id.fl_container)
            }

        }
    }

    override fun onBackPressed() {
        val isCanNavi = supportFragmentManager.navigateBack()
        if (!isCanNavi) {
            super.onBackPressed()
            //finish()
        }

    }

    companion object {
        const val TYPE = "type"
        const val SELECT_APP_FRAGMENT = "select_app_fragment"
        const val SYS_NOTIFICATION_FRAGMENT = "sys_notification_fragment"
        const val CUSTOME_CHANNEL_FRAGMENT = "custom_channel_fragment"
    }

}